package com.sunwayhorizo.health.hl7.rim;

import com.sunwayhorizo.health.common.DataTypeUtil;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.factories.ReferenceModifier;
import com.sunwayhorizo.health.hl7.persistent.RimCoreActCdSets;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQuery;

import org.jboss.seam.annotations.Name;

import static com.sunwayhorizo.health.hl7.vocabulary.ActCdSetCode.*;


@Name("Account")
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("ACCT")
@NamedQuery(name = "Account.findAll", query = "select o from Account o")
public class Account extends Act implements Serializable {
    
/*    public IVL_MO allowedBalanceQuantity;
    public MO balanceAmt;
    public CE currencyCode;
    public RTO_MO_PQ interestRateQuantity;
    public ST name;
*/    
    public Account() throws Hl7Exception {
    }
    
    public Account(ReferenceModifier referencemodifier)
    {
        super(referencemodifier);
    }
    
/*    public void setAllowedBalanceQuantity(IVL_MO allowedBalanceQuantity) {
        this.allowedBalanceQuantity = allowedBalanceQuantity;
    }

    public IVL_MO getAllowedBalanceQuantity() {
        return allowedBalanceQuantity;
    }

    public void setBalanceAmt(MO balanceAmt) {
        this.balanceAmt = balanceAmt;
    }

    public MO getBalanceAmt() {
        return balanceAmt;
    }
*/
    public void setCurrencyCode(CE ce) {
    	if(null != ce && ce.codeSystemEnName()!=null && ce.codeName()!= null)
        {
            setRimCoreActCdSets(ce, ACCURRCDSETCODE);
        }
        else
        {
            this.setAcCurrCode(ce.code().toString());
        }
    }

    public CE getCurrencyCode() throws Hl7Exception {
    	if (this.getAcCurrCode().equals(ACCURRCDSETCODE.toString()))
        {
            for (RimCoreActCdSets actCdSets : this.getActCdSetsList())
            {
                if (this.getAcCurrCode().equals(actCdSets.getAttributeTypeCode()))
                {
                    return DataTypeUtil.getCE(actCdSets);
                }
            }            
        }
        else
            return DataTypeUtil.getCE(this.getAcCurrCode()); 
        return null;
    }
/*
    public void setInterestRateQuantity(RTO_MO_PQ interestRateQuantity) {
        this.interestRateQuantity = interestRateQuantity;
    }

    public RTO_MO_PQ getInterestRateQuantity() {
        return interestRateQuantity;
    }
*/
    public void setName(ST name) {
        this.setAcAccountName(name.toString());
    }

    public ST getName() throws Hl7Exception {
        return DataTypeUtil.getST(this.getAcAccountName());  
    }
    
    //Account
        @Column(name = "AC_ACCOUNT_NAME")    private String acAccountName;
        @Column(name = "AC_ALLOWED_BAL_END_CURR_CODE")    private String acAllowedBalEndCurrCode;
        @Column(name = "AC_ALLOWED_BAL_END_INCL_FLAG")    private String acAllowedBalEndInclFlag;
        @Column(name = "AC_ALLOWED_BAL_IVL_CURR_CODE")    private String acAllowedBalIvlCurrCode;
        @Column(name = "AC_ALLOWED_BAL_QTY_END_AMT")    private Double acAllowedBalQtyEndAmt;
        @Column(name = "AC_ALLOWED_BAL_QTY_END_TXT")    private String acAllowedBalQtyEndTxt;
        @Column(name = "AC_ALLOWED_BAL_QTY_IVL_TXT")    private String acAllowedBalQtyIvlTxt;
        @Column(name = "AC_ALLOWED_BAL_QTY_START_AMT")    private Double acAllowedBalQtyStartAmt;
        @Column(name = "AC_ALLOWED_BAL_QTY_START_TXT")    private String acAllowedBalQtyStartTxt;
        @Column(name = "AC_ALLOWED_BAL_START_CURR_CODE")    private String acAllowedBalStartCurrCode;
        @Column(name = "AC_ALLOWED_BAL_START_INCL_FLAG")    private String acAllowedBalStartInclFlag;
        @Column(name = "AC_BALANCE_AMT")    private Double acBalanceAmt;
        @Column(name = "AC_BALANCE_AMT_TXT")    private String acBalanceAmtTxt;
        @Column(name = "AC_BAL_AMT_CURR_CODE")    private String acBalAmtCurrCode;
        @Column(name = "AC_CURR_CODE")    
        private String acCurrCode = ACCURRCDSETCODE.toString();
        @Column(name = "AC_DEN_INTT_RATE_QTY_TXT")    private String acDenInttRateQtyTxt;
        @Column(name = "AC_DEN_INTT_RATE_QTY_UOM_CODE")    private String acDenInttRateQtyUomCode;
        @Column(name = "AC_NUMER_INTT_RATE_CURR_CODE")    private String acNumerInttRateCurrCode;
        @Column(name = "AC_NUMER_INTT_RATE_QTY_AMT")    private Double acNumerInttRateQtyAmt;
        @Column(name = "AC_NUMER_INTT_RATE_QTY_TXT")    private String acNumerInttRateQtyTxt;
        

        private String getAcAccountName() {
            return acAccountName;
        }
        
        private void setAcAccountName(String acAccountName) {
            this.acAccountName = acAccountName;
        }

        private String getAcAllowedBalEndCurrCode() {
            return acAllowedBalEndCurrCode;
        }
        
        private void setAcAllowedBalEndCurrCode(String acAllowedBalEndCurrCode) {
            this.acAllowedBalEndCurrCode = acAllowedBalEndCurrCode;
        }

        private String getAcAllowedBalEndInclFlag() {
            return acAllowedBalEndInclFlag;
        }

        private void setAcAllowedBalEndInclFlag(String acAllowedBalEndInclFlag) {
            this.acAllowedBalEndInclFlag = acAllowedBalEndInclFlag;
        }

        private String getAcAllowedBalIvlCurrCode() {
            return acAllowedBalIvlCurrCode;
        }

        private void setAcAllowedBalIvlCurrCode(String acAllowedBalIvlCurrCode) {
            this.acAllowedBalIvlCurrCode = acAllowedBalIvlCurrCode;
        }

        private Double getAcAllowedBalQtyEndAmt() {
            return acAllowedBalQtyEndAmt;
        }

        private void setAcAllowedBalQtyEndAmt(Double acAllowedBalQtyEndAmt) {
            this.acAllowedBalQtyEndAmt = acAllowedBalQtyEndAmt;
        }

        private String getAcAllowedBalQtyEndTxt() {
            return acAllowedBalQtyEndTxt;
        }

        private void setAcAllowedBalQtyEndTxt(String acAllowedBalQtyEndTxt) {
            this.acAllowedBalQtyEndTxt = acAllowedBalQtyEndTxt;
        }

        private String getAcAllowedBalQtyIvlTxt() {
            return acAllowedBalQtyIvlTxt;
        }

        private void setAcAllowedBalQtyIvlTxt(String acAllowedBalQtyIvlTxt) {
            this.acAllowedBalQtyIvlTxt = acAllowedBalQtyIvlTxt;
        }

        private Double getAcAllowedBalQtyStartAmt() {
            return acAllowedBalQtyStartAmt;
        }

        private void setAcAllowedBalQtyStartAmt(Double acAllowedBalQtyStartAmt) {
            this.acAllowedBalQtyStartAmt = acAllowedBalQtyStartAmt;
        }

        private String getAcAllowedBalQtyStartTxt() {
            return acAllowedBalQtyStartTxt;
        }

        private void setAcAllowedBalQtyStartTxt(String acAllowedBalQtyStartTxt) {
            this.acAllowedBalQtyStartTxt = acAllowedBalQtyStartTxt;
        }

        private String getAcAllowedBalStartCurrCode() {
            return acAllowedBalStartCurrCode;
        }

        private void setAcAllowedBalStartCurrCode(String acAllowedBalStartCurrCode) {
            this.acAllowedBalStartCurrCode = acAllowedBalStartCurrCode;
        }

        private String getAcAllowedBalStartInclFlag() {
            return acAllowedBalStartInclFlag;
        }

        private void setAcAllowedBalStartInclFlag(String acAllowedBalStartInclFlag) {
            this.acAllowedBalStartInclFlag = acAllowedBalStartInclFlag;
        }

        private Double getAcBalanceAmt() {
            return acBalanceAmt;
        }

        private void setAcBalanceAmt(Double acBalanceAmt) {
            this.acBalanceAmt = acBalanceAmt;
        }

        private String getAcBalanceAmtTxt() {
            return acBalanceAmtTxt;
        }

        private void setAcBalanceAmtTxt(String acBalanceAmtTxt) {
            this.acBalanceAmtTxt = acBalanceAmtTxt;
        }

        private String getAcBalAmtCurrCode() {
            return acBalAmtCurrCode;
        }

        private void setAcBalAmtCurrCode(String acBalAmtCurrCode) {
            this.acBalAmtCurrCode = acBalAmtCurrCode;
        }

        private String getAcCurrCode() {
            return acCurrCode;
        }

        private void setAcCurrCode(String acCurrCode) {
            this.acCurrCode = acCurrCode;
        }

        private String getAcDenInttRateQtyTxt() {
            return acDenInttRateQtyTxt;
        }

        private void setAcDenInttRateQtyTxt(String acDenInttRateQtyTxt) {
            this.acDenInttRateQtyTxt = acDenInttRateQtyTxt;
        }

        private String getAcDenInttRateQtyUomCode() {
            return acDenInttRateQtyUomCode;
        }

        private void setAcDenInttRateQtyUomCode(String acDenInttRateQtyUomCode) {
            this.acDenInttRateQtyUomCode = acDenInttRateQtyUomCode;
        }

        private String getAcNumerInttRateCurrCode() {
            return acNumerInttRateCurrCode;
        }

        private void setAcNumerInttRateCurrCode(String acNumerInttRateCurrCode) {
            this.acNumerInttRateCurrCode = acNumerInttRateCurrCode;
        }

        private Double getAcNumerInttRateQtyAmt() {
            return acNumerInttRateQtyAmt;
        }

        private void setAcNumerInttRateQtyAmt(Double acNumerInttRateQtyAmt) {
            this.acNumerInttRateQtyAmt = acNumerInttRateQtyAmt;
        }

        private String getAcNumerInttRateQtyTxt() {
            return acNumerInttRateQtyTxt;
        }

        private void setAcNumerInttRateQtyTxt(String acNumerInttRateQtyTxt) {
            this.acNumerInttRateQtyTxt = acNumerInttRateQtyTxt;
        }


}
